package com.jz.cash.client.query;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageBean<T> implements Serializable {

    private List<T> items;

    private int total;

    private int totalPage;

    private int currentPage;

    private int pageSize;

    public static PageBean init(int total, int page, int size) {
        PageBean pageBean = new PageBean();

        pageBean.setTotal(total);
        pageBean.setCurrentPage(page);
        pageBean.setPageSize(size);
        pageBean.setTotalPage(total % size == 0 ? total / size : (total / size) + 1);

        return pageBean;

    }
}
